package swing.chapter03;

import swing.util.SwingConsle;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Random;

public class TextPane extends JFrame {
    private JButton b = new JButton("Add Test");
    private JTextPane tp = new JTextPane();
    private static Random random = new Random();

    public TextPane(){
        b.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                for(int i=0;i<10;i++){
                    tp.setText(tp.getText() + random.nextInt(100000) + "\n");
                }
            }
        });
        add(new JScrollPane(tp));
        add(BorderLayout.SOUTH, b);
    }

    public static void main(String[] args) {
        SwingConsle.run(new TextPane(), 475,425);
    }
}
